I have a module with a 'PER' attribute that is numbered sequentially according to another 'ER' attribute. So I created this for loop which numbers it perfectly in one module and then gives me an error on the last line during another.
Object o }
When it gets to the last line: o.PER = count_5 it halts the execution and says "expected int attribute." I've found out that in one module the attribute, PER, is defined as text while the other defines it as an integer. Is there a way to check the value and define it accordingly?
if
stevenson - Mon Jul 08 18:46:25 EDT 2013 |
Re: expected int attribute Hello Stevenson, converting a integer to string can be done by simply putting double quotes ( "" ) behind it. So in your case that would be:
Actually assigning a string (which contains only numbers) to a integer works quite well. So you don't even need to check for the attribute type but can just use above statement regardless of the attribute's type. - Michael |
Re: expected int attribute To clarify Mike, you CAN assign a "string" to an "int" attribute so long as the string looks like an integer. Thus, you can turn your int into a string and this line should work for both modules:
You cannot do the opposite, put an "int" into a "string" attr, as you found out. Seems to me though you have a project admin problem if you have the same attribute defined diffferently in more than one module. You <<should>> fix the rouge module.
Actually it is better to turn off History for "PER_Temp" while copying, and turn it back on afterwards in order to suppress History "23 = 23" which provides no value. or just delete PER and recreat it type "int", and run your original script to populate it. -Louie BTW, in your original when "ER" is not "5ms" do you not want to erase "PER"? |